import React from 'react'
import basicStyle from '../common/basic.scss'
import { openImageWindow } from './openImageWindow'
import { getScreenShotOfStep } from '../../source/getData'

export const ScreenShotViewer = ({ planId, stepId, screenshotId }) => {
    if (screenshotId) {
        const openWin = () => {
            getScreenShotOfStep({ planId, stepId, screenshotId })
                .then(response => {
                    if (response && response.data && response.data.length) {
                        const screenshot = response.data[0].screenshot
                        openImageWindow(screenshot)()
                    }
                })
        }

        return <img className={basicStyle.icon_img} title='查看页面截屏' src={`../../../public/images/screenshot.png`} onClick={openWin} />
    } else {
        return null
    }
}